#ifndef CORRELATIONBASEDCF_H_
#define CORRELATIONBASEDCF_H_

#include <algorithm>
#include <vector>
#include <cmath>
#include <list>
#include <map>

#include "../CFAlgorithm.h"
#include "../../repository/persistence/DAOFactory.h"

#include "../../util/Log.h"

using namespace std;

typedef map<pair<int, int> , int> matrix;

class CorrelationBasedCF: public CFAlgorithm {
private:
	int active_uid;
	double avr_a_user;
	double p_avr_a_user;

	vector<int> itens;
	vector<int> users;
	matrix ratings;

	DAOFactory* daoFactory;

	int populateRMatrix();
	double pearsonRatingsAverage(int& uid);
	double ratingsAverage(int& uid, int& cid);
	double pearsonCorrelation(int& uid);
	double calculatePrediction(int& cid);
public:
	CorrelationBasedCF();
	virtual double predict(int cid);
	virtual vector<string> listTopN(int n);
	virtual ~CorrelationBasedCF();
};

#endif /* CORRELATIONBASEDCF_H_ */
